package com.comment.project.oss;

import com.aliyun.oss.ClientException;
import com.aliyun.oss.HttpMethod;
import com.aliyun.oss.OSSClient;
import com.aliyun.oss.OSSException;
import com.aliyun.oss.model.GeneratePresignedUrlRequest;
import com.aliyun.oss.model.GetObjectRequest;

import java.io.File;
import java.io.IOException;

/**
 * @author liupenghui
 * @date 2018/7/26
 * @desc：
 */
public class GetOSSUrl {
    private static String endpoint = "http://oss-cn-beijing.aliyuncs.com";
    private static String accessKeyId = "LTAIv2HaWLvh3TUB";
    private static String accessKeySecret = "HtfWNa1LO2ZI2aYqZ7OQ073zeah2rO";
    private static String bucketName = "five-zero-two";
    private static String objectName = "gou.jpg";

    private static String securityToken = "qwer1234";


    public static void main(String[] args) {
        OSSClient ossClient = new OSSClient(endpoint, accessKeyId, accessKeySecret,securityToken);

        GeneratePresignedUrlRequest request = new GeneratePresignedUrlRequest(bucketName, objectName, HttpMethod.PUT);

//        // 设置URL过期时间为1小时。
//        Date expiration = new Date(new Date().getTime() + 3600 * 1000);
//        request.setExpiration(expiration);
    }
}
